<?php

abstract class Mac_Db_Query_Abstract
{
    protected $result;
    
    public abstract function __toString();
    
    public function execute()
    {
        $this->result = Mac_Db_Connection::executeQuery($this->__toString());
        if ($this->result === false) {
            Mac_Logger::getLogger()->error(Mac_Db_Connection::getLastError());
            echo Mac_Db_Connection::getLastError(); // TODO: virer ça
        }
        return $this->result;
    }
    
    public function getFirstAsAssoc ()
    {
        $this->execute();
        if ($this->result !== false) {
            return mysql_fetch_assoc($this->result);
        } else {
            return false;
        }
    }
}